package top.v5it.japi.plus.example.jdbc.service.impl;

import org.springframework.stereotype.Service;
import top.v5it.japi.plus.data.jdbc.service.support.JapiMybatisSimpleService;
import top.v5it.japi.plus.example.jdbc.domain.Account;
import top.v5it.japi.plus.example.jdbc.domain.AccountVo;
import top.v5it.japi.plus.example.jdbc.repositoy.AccountRepository;
import top.v5it.japi.plus.example.jdbc.service.AccountService;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.List;

/**
 * @author zhanpu
 * @date 2022/8/4
 */
@Service(AccountService.SERVICE_NAME)
public class AccountServiceImpl extends JapiMybatisSimpleService<AccountRepository, Account, Long> implements AccountService {

    @Override
    public Account searchAccount(Account account) {
        return this.japiRepository.selectOneByCondition(account);
    }

    @Override
    public List<AccountVo> searchTest() {
        final AccountVo.Resource resource1 = new AccountVo.Resource()
                .setTel("6790")
                .setAccountNumber("567890")
                .setAmount(1233L);
        final AccountVo accountVo1 = new AccountVo()
                .setResource(resource1)
                .setName("jack")
                .setId(1L)
                .setCreatedTime(LocalDateTime.now(ZoneId.systemDefault()))
                .setUpdatedTime(LocalDateTime.now(ZoneId.systemDefault()))
                .setRemark("test 123")
                .setStatus(Byte.valueOf("1"));

        final AccountVo.Resource resource2 = new AccountVo.Resource()
                .setTel("2345")
                .setAccountNumber("9876")
                .setAmount(1233L);
        final AccountVo accountVo2 = new AccountVo()
                .setResource(resource2)
                .setName("jie")
                .setId(2L)
                .setCreatedTime(LocalDateTime.now(ZoneId.systemDefault()))
                .setUpdatedTime(LocalDateTime.now(ZoneId.systemDefault()))
                .setRemark("test 987")
                .setStatus(Byte.valueOf("0"));
        return Arrays.asList(accountVo1, accountVo2);
    }

}
